package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.RewardVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.domain.entity.AiRecordingDuan;
import com.ruoyi.system.service.IAiRecordingDuanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * AI录音记录每一段（多条组成）Controller
 *
 * @author ruoyi
 * @date 2025-03-06
 */
@RestController
@RequestMapping("/system/duan")
public class AiRecordingDuanController extends BaseController
{
    @Autowired
    private IAiRecordingDuanService aiRecordingDuanService;

    /**
     * 查询AI录音记录每一段（多条组成）列表
     */
//    @PreAuthorize("@ss.hasPermi('system:duan:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiRecordingDuan aiRecordingDuan)
    {
        startPage();
        List<AiRecordingDuan> list = aiRecordingDuanService.selectAiRecordingDuanList(aiRecordingDuan);
        return getDataTable(list);
    }

    /**
     * 导出AI录音记录每一段（多条组成）列表
     */
//    @PreAuthorize("@ss.hasPermi('system:duan:export')")
    @Log(title = "AI录音记录每一段（多条组成）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiRecordingDuan aiRecordingDuan)
    {
        List<AiRecordingDuan> list = aiRecordingDuanService.selectAiRecordingDuanList(aiRecordingDuan);
        ExcelUtil<AiRecordingDuan> util = new ExcelUtil<AiRecordingDuan>(AiRecordingDuan.class);
        util.exportExcel(response, list, "AI录音记录每一段（多条组成）数据");
    }




    @GetMapping("/selectRewardPrivate")
    public AjaxResult selectRewardPrivate()
    {
        String result = aiRecordingDuanService.selectReward();
        return AjaxResult.success(result);
    }

    @GetMapping("/selectRewardDay")
    public AjaxResult selectRewardDay()
    {
        String result = aiRecordingDuanService.selectRewardDay();
        return AjaxResult.success(result);
    }

    @GetMapping("/selectRewardSum")
    public AjaxResult selectRewardSum()
    {
        String result = aiRecordingDuanService.selectRewardSum();
        return AjaxResult.success(result);
    }

    /**
     * 获取AI录音记录每一段（多条组成）详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:duan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiRecordingDuanService.selectAiRecordingDuanById(id));
    }

    /**
     * 新增AI录音记录每一段（多条组成）
     */
//    @PreAuthorize("@ss.hasPermi('system:duan:add')")
    @Log(title = "AI录音记录每一段（多条组成）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiRecordingDuan aiRecordingDuan)
    {
        return toAjax(aiRecordingDuanService.insertAiRecordingDuan(aiRecordingDuan));
    }

    /**
     * 修改AI录音记录每一段（多条组成）
     */
//    @PreAuthorize("@ss.hasPermi('system:duan:edit')")
    @Log(title = "AI录音记录每一段（多条组成）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiRecordingDuan aiRecordingDuan)
    {
        return toAjax(aiRecordingDuanService.updateAiRecordingDuan(aiRecordingDuan));
    }

    /**
     * 删除AI录音记录每一段（多条组成）
     */
//    @PreAuthorize("@ss.hasPermi('system:duan:remove')")
    @Log(title = "AI录音记录每一段（多条组成）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiRecordingDuanService.deleteAiRecordingDuanByIds(ids));
    }
}
